package com.tjsinfo.tjsoa.mail.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.mail.bo.ITjsEmailFolderBo;
import com.tjsinfo.tjsoa.mail.bo.ITjsmailBo;
import com.tjsinfo.tjsoa.mail.vo.TjsEmailFolder;
import com.tjsinfo.tjsoa.mail.vo.Tjsmail;
import com.tjsinfo.tjsoa.system.vo.User;

/**
 * 查询已发邮件内容
 * @author wangxiaowei
 *
 */
public class SelectOneMailAction extends Action{
	private ITjsmailBo tjsmailBo;
	private ITjsEmailFolderBo tjsEmailFolderBo;
	public ITjsmailBo getTjsmailBo() {
		return tjsmailBo;
	}
	public ITjsEmailFolderBo getTjsEmailFolderBo() {
		return tjsEmailFolderBo;
	}
	public void setTjsEmailFolderBo(ITjsEmailFolderBo tjsEmailFolderBo) {
		this.tjsEmailFolderBo = tjsEmailFolderBo;
	}
	public void setTjsmailBo(ITjsmailBo tjsmailBo) {
		this.tjsmailBo = tjsmailBo;
	}
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String id = request.getParameter("id");
		Tjsmail tjsmail = tjsmailBo.selectByID(id).get(0);//邮件
		
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		if (user.getUser_id()!=tjsmail.getTjsmailUserid()) {
			tjsmailBo.updateSendMailRead(tjsmail.getTjsmailId(), 2);
		}
		
		request.setAttribute("tjsmail", tjsmail);
		List<TjsEmailFolder> list2 = tjsEmailFolderBo.selectByUserId(SessionUser.getUserId(request));//文件夹
		request.setAttribute("foldlist", list2);
		return mapping.findForward("ok");
	}
	
}
